Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TemplateHash label #165

Merged
merged 2 commits into from
Dec 24, 2023
Merged

Add TemplateHash label #165

merged 2 commits into from
Dec 24, 2023

Conversation

dwertent
Copy link

@dwertent dwertent commented Dec 24, 2023

Type

Enhancement


Description

This PR introduces several enhancements:

  • It retrieves the pod template hash and assigns it to the watchedContainer.TemplateHash variable in pkg/applicationprofilemanager/v1/applicationprofile_manager.go.
  • It handles the error if the workload parent calculation fails in pkg/applicationprofilemanager/v1/applicationprofile_manager.go.
  • The structure of WatchedContainerData in pkg/utils/utils.go has been rearranged, and a new field TemplateHash has been added.
  • The function GetLabels in pkg/utils/utils.go has been updated to include TemplateHash in the labels if it is not an empty string.
  • The version of github.com/kubescape/k8s-interface has been updated from v0.0.152 to v0.0.154 in go.mod and go.sum.

PR changes walkthrough

Relevant files                                                                                                                                 
Enhancement
2 files
applicationprofile_manager.go                                                             
    pkg/applicationprofilemanager/v1/applicationprofile_manager.go

    The code retrieves the pod template hash and assigns it to
    the watchedContainer.TemplateHash variable. Also, it
    handles the error if the workload parent calculation fails.

+4/-0
utils.go                                                                                                       
    pkg/utils/utils.go

    The structure of WatchedContainerData has been rearranged,
    and a new field TemplateHash has been added. The function
    GetLabels has been updated to include TemplateHash in
    the labels if it is not an empty string.

+18/-13
Dependencies
2 files
go.mod                                                                                                           
    go.mod

    The version of github.com/kubescape/k8s-interface has been
    updated from v0.0.152 to v0.0.154.

+1/-1
go.sum                                                                                                           
    go.sum

    The checksums for github.com/kubescape/k8s-interface have
    been updated to reflect the new version v0.0.154.

+2/-2

User description

Overview

Signed-off-by: David Wertenteil <[email protected]>
@dwertent dwertent added the release Create release label Dec 24, 2023
@codiumai-pr-agent-free codiumai-pr-agent-free bot added the enhancement New feature or request label Dec 24, 2023
Copy link

PR Description updated to latest commit (75bac86)

Copy link

PR Analysis

  • 🎯 Main theme: Adding a TemplateHash label to the WatchedContainerData structure and updating dependencies
  • 📝 PR summary: This PR introduces a new TemplateHash field to the WatchedContainerData structure and updates the GetLabels function to include this new field if it is not empty. It also handles the error if the workload parent calculation fails and updates the version of the kubescape/k8s-interface dependency.
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 2, because the PR is relatively small and straightforward, but it does involve some changes to the structure and error handling.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR looks good overall. It would be beneficial to include some tests for the new changes, especially for the error handling part. Also, it would be helpful to have some comments explaining the purpose and usage of the new TemplateHash field.

  • 🤖 Code feedback:
    relevant filepkg/applicationprofilemanager/v1/applicationprofile_manager.go
    suggestion      It would be better to handle the error when getting the pod template hash, instead of ignoring it. This will help in debugging if any issues arise. [important]
    relevant linewatchedContainer.TemplateHash, _ = pod.GetLabel("pod-template-hash")

    relevant filepkg/utils/utils.go
    suggestion      It would be beneficial to add a check for the TemplateHash field before adding it to the labels. If the field is empty, it should not be added. [medium]
    relevant lineif watchedContainer.TemplateHash != "" {

How to use

Instructions

To invoke the PR-Agent, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.
see the tools guide for more details.

To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

Signed-off-by: David Wertenteil <[email protected]>
Copy link

Summary:

  • License scan: success
  • Credentials scan: success
  • Vulnerabilities scan: failure
  • Unit test: success
  • Go linting: success

@dwertent dwertent merged commit 91d9b78 into main Dec 24, 2023
6 checks passed
@dwertent dwertent deleted the fix-naming-convention branch December 24, 2023 17:33
dwertent pushed a commit that referenced this pull request Jan 2, 2024
* support syft types

Signed-off-by: DanielGrunbergerCA <[email protected]>

* fix func call

Signed-off-by: DanielGrunbergerCA <[email protected]>

* init map

Signed-off-by: DanielGrunbergerCA <[email protected]>

* update go:

Signed-off-by: DanielGrunbergerCA <[email protected]>

* update go mod

Signed-off-by: David Wertenteil <[email protected]>

* skip exec events with empty path

Signed-off-by: Matthias Bertschy <[email protected]>

* ignore ebpf events with empty container name

Signed-off-by: Matthias Bertschy <[email protected]>

* avoid race condition between container start and activity reporting

Signed-off-by: Matthias Bertschy <[email protected]>

* remove secrets from obj

Signed-off-by: David Wertenteil <[email protected]>

* Add TemplateHash label (#165)

* Add TemplateHash label

Signed-off-by: David Wertenteil <[email protected]>

* fixed test

Signed-off-by: David Wertenteil <[email protected]>

---------

Signed-off-by: David Wertenteil <[email protected]>

* Bump k8s-interface to 155 (#166)

* bump k8s-interface to 155

Signed-off-by: David Wertenteil <[email protected]>

* fixed name

Signed-off-by: David Wertenteil <[email protected]>

---------

Signed-off-by: David Wertenteil <[email protected]>

* Adding pod-template-hash label (#167)

* Adding pod-template-hash label

Signed-off-by: David Wertenteil <[email protected]>

* bump k8-interface pkg

Signed-off-by: David Wertenteil <[email protected]>

---------

Signed-off-by: David Wertenteil <[email protected]>

* Call InstanceIDToSlug instead of GetSlug

Signed-off-by: David Wertenteil <[email protected]>

* support syft types

Signed-off-by: DanielGrunbergerCA <[email protected]>

* fix func call

Signed-off-by: DanielGrunbergerCA <[email protected]>

* init map

Signed-off-by: DanielGrunbergerCA <[email protected]>

* update go:

Signed-off-by: DanielGrunbergerCA <[email protected]>

* update go mod

Signed-off-by: David Wertenteil <[email protected]>

* remove secrets from obj

Signed-off-by: David Wertenteil <[email protected]>

---------

Signed-off-by: DanielGrunbergerCA <[email protected]>
Signed-off-by: David Wertenteil <[email protected]>
Signed-off-by: Matthias Bertschy <[email protected]>
Co-authored-by: DanielGrunbergerCA <[email protected]>
Co-authored-by: Matthias Bertschy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request release Create release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant